/**
 * 
 * @author libai
 *
 *you can find a num from a sorted array
 */
public class SortedArrayFinder implements Finder {
	public int find(int[] array, int d) {
		/**
		 * the place or the inserted place of the num be printed and returned
		 */
		int length=array.length,high=length-1,low=0,m=0;
		while(high>=low)
		{
			m=(high+low)/2;
			if(array[m]==d)
			{
				System.out.println("the place is:"+m);
				return m;
			}
			if(array[m]>d)
				high=m-1;
			else
				low=m+1;
		
		}
		if(d>array[length-1])
		{
			System.out.println("the inserted place is:"+length);
			return length;
		}
		System.out.println("the inserted place is:"+low);
		return low;
		
		
	}
	
}